<?php

//
// +---------------------------------------------------------+
// | 开发组
// +---------------------------------------------------------+
// | Copyrigh  (c)  2020 The PHP Group
// +---------------------------------------------------------+
// | 广告
// +---------------------------------------------------------+
// | zxc
// | php后端开发
// |
// +———————————————————+
//

namespace App\Models\Admin;

use Illuminate\Database\Eloquent\Model;

class Account extends Model
{

    protected $table = 'account';
    protected $primaryKey = 'id';
    protected $dateFormat = 'U'; // 时间戳
    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s'
    ];

    /**
     * 获取信息
     *
     * @param [type] $id
     * @param string $str
     * @return void
     * @Author Afree 2020-08-03
     */
    public static function getInfoById($id, $str = '')
    {
        if ($id > 0) {
            $account = self::where(['id' => $id])->first();
            // v($account);
            if ($account) {
                return $str ? $account[$str] : $account;
            }
        }
        return $str ? '' : [];
    }
}